<template>
	<view>
		<view class="pages">
			<view class="item flex align-items ">
				<view class="item_fu">关联工作票</view>
				<view class="item_right  flex align-items" >
					<u-input v-model="fault_class_str" placeholder="请选择" :fontSize="16" placeholderClass="placeholderClass" @focus="workShow = true"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16" v-if="!fault_class_str"></u-icon>
					<u-icon name="close" color="#CCCCCC" :size="16" v-if="fault_class_str" @click="clsoeWork"></u-icon>
				</view>
			</view>
			<view class="herder">
				基本信息
			</view>
			<view class="item flex align-items ">
				<view class="item_fu">操作任务</view>
				<view class="item_right  flex align-items" @click="templateBtn">
					<u-input v-model="form.name" placeholder="请选择" :fontSize="16" :readonly="true"
						placeholderClass="placeholderClass" style="pointer-events:none"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view>
			<!-- 	<view class="item flex align-items ">
				<view class="item_left">操作任务</view>
				<view class="item_right">
					<u-input placeholder="请输入" v-model="form.taskName" :fontSize="16"
						placeholderClass="placeholderClass"></u-input>
				</view>
			</view> -->
			<!-- 	<view class="item flex align-items ">
				<view class="item_fu">操作设备</view>
				<view class="item_right  flex align-items" @click="claick('device','deviceName',3)">
					<u-input placeholder="请选择" :fontSize="16" :readonly="true" placeholderClass="placeholderClass"
						style="pointer-events:none" v-model="form.deviceName"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view> -->
			<view class="item flex align-items ">
				<view class="item_left">操作票专业</view>
				<view class="item_right  flex align-items" @click="categoryShow = true">
					<u-input v-model="form.category" placeholder="请选择" :fontSize="16" :readonly="true"
						placeholderClass="placeholderClass" style="pointer-events:none"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view>
			<view class="item flex align-items ">
				<view class="item_fu">期</view>
				<view class="item_right">
					<u-input v-model="form.edition" placeholder="请输入" :fontSize="16"
						placeholderClass="placeholderClass"></u-input>
				</view>
			</view>
			<!-- 	<view class="item flex align-items ">
				<view class="item_left">页数</view>
				<view class="item_right">
					<u-input v-model="form.numberPages" placeholder="请输入" :fontSize="16"
						placeholderClass="placeholderClass" type="number"></u-input>
				</view>
			</view> -->
			<view class="item flex align-items ">
				<view class="item_left">操作部门</view>
				<view class="item_right  flex align-items" @click="claick('deptId','depatName',0)">
					<u-input placeholder="请选择" :fontSize="16" :readonly="true" placeholderClass="placeholderClass"
						v-model="form.depatName" style="pointer-events:none"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view>
			<view class="item flex align-items ">
				<view class="item_left">操作人</view>
				<view class="item_right  flex align-items" @click="claick('operateUserId','operateUserName',1)">
					<u-input placeholder="请选择" :fontSize="16" :readonly="true" placeholderClass="placeholderClass"
						v-model="form.operateUserName" style="pointer-events:none"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view>
			<view class="item flex align-items ">
				<view class="item_left">监护人</view>
				<view class="item_right  flex align-items" @click="claick('guardianUserId','guardianUserName',2)">
					<u-input v-model="form.guardianUserName" placeholder="请选择" :fontSize="16" :readonly="true"
						placeholderClass="placeholderClass" style="pointer-events:none"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view>
			<view class="item flex align-items ">
				<view class="item_left">一级审批 </view>
				<view class="item_right  flex align-items" @click="claick('monitorUserId','monitorUserName',2)">
					<u-input placeholder="请选择" :fontSize="16" :readonly="true" placeholderClass="placeholderClass"
						v-model="form.monitorUserName" style="pointer-events:none"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view>
			<view class="item flex align-items ">
				<view class="item_left">二级审批</view>
				<view class="item_right  flex align-items" @click="claick('shiftSupervisorId','shiftSupervisorName',2)">
					<u-input placeholder="请选择" :fontSize="16" :readonly="true" placeholderClass="placeholderClass"
						v-model="form.shiftSupervisorName" style="pointer-events:none"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view>

			<!-- <view class="item flex align-items ">
				<view class="item_left">作业前准备</view>
			</view>
			<view class=" margin-top10">
				<u-textarea v-model="form.preparationContent" placeholder="请输入" :fontSize="16"
					placeholderClass="placeholderClass" style="font-size: 16px;"></u-textarea>
			</view> -->
		</view>
		<!-- <view style="background-color: #F6F6F6;height: 15rpx;"></view>
		<view class="pages">
			<view class="item   flex align-items ">
				<view class="item_left" style="width: 240rpx;">员工授权停工</view>
			</view>
			<view class="margin-top10 ">
				<u-textarea v-model="form.shutdownContent" height="220" placeholder="请输入" :fontSize="16"
					placeholderClass="placeholderClass" style="font-size: 32rpx;"></u-textarea>
			</view>
		</view> -->
		<view style="background-color: #F6F6F6;height: 10rpx;"></view>
		<view class="pages">
			<view class="item flex align-items " style="border: none;" @click="jumpTos('/pages/newRisks/newRisks',1)">
				<view class="item_fu" style="width: 240rpx;">风险控制措施</view>
				<view class="item_right  flex align-items">
					<u-input placeholder="请选择 " v-model="form.listRisk.length" :fontSize="16" :readonly="true"
						placeholderClass="placeholderClass" color="#267DFF" inputAlign="right"
						style="pointer-events:none"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view>
		</view>
		<view style="background-color: #F6F6F6;height: 10rpx;"></view>
		<view class="pages">
			<view class="item flex align-items " style="border: none;"
				@click="jumpTos('/pages/newOperation/newOperation',2)">
				<view class="item_left">操作项目</view>
				<view class="item_right  flex align-items">
					<u-input placeholder="请选择 " v-model="form.listProcess.length" :fontSize="16" :readonly="true"
						placeholderClass="placeholderClass" color="#267DFF" inputAlign="right"
						style="pointer-events:none"></u-input>
					<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
				</view>
			</view>
		</view>
		<view style="background-color: #F6F6F6;height: 10rpx;"></view>
		<view class="pages">
			<view class="item flex align-items " style="border: none;">
				<view class="item_fu a">操作</view>
				<view class="item_right  flex align-items">
					<div @click="form.operateType = 1" class="mshh">
						<image src="/static/img/index/yixuanzhong.png" mode="" v-if="form.operateType !=1"></image>
						<image src="/static/img/index/xuanzhong.png" mode="" v-if="form.operateType ==1"></image>
						<div>监护操作</div>
					</div>
					<div @click="form.operateType = 2" class="mshh">
						<image src="/static/img/index/yixuanzhong.png" mode="" v-if="form.operateType !=2"></image>
						<image src="/static/img/index/xuanzhong.png" mode="" v-if="form.operateType ==2"></image>
						<div>单人操作</div>
					</div>
				</view>
			</view>
		</view>
		<view style="background-color: #F6F6F6;height: 10rpx;"></view>
		<view class="pages">
			<view class="item flex align-items " style="border: none;" @click="pickerAdd">
				<view class="item_fu a">关联票</view>
				<view class="item_right  flex align-items ">
					<u-input placeholder="请选择 " v-model="form.parentName" :fontSize="16" :readonly="true"
						placeholderClass="placeholderClass" inputAlign="right" style="pointer-events:none"></u-input>
					<div class="flex align-items ">
						<u-icon name="close-circle" color="#CCCCCC" :size="16" v-if="form.parentName"
							@click.stop.native="clarParen"></u-icon>
						<u-icon name="arrow-right" color="#CCCCCC" :size="16"></u-icon>
					</div>
				</view>
			</view>
		</view>
		<view style="background-color: #F6F6F6;height: 10rpx;"></view>
		<view class="pages">
			<view class="items flex align-items justify-content-between " style="height: 136rpx;">
				<view class="item_fu">附件</view>
				<view class="item_upload" @click="upload" v-if="!form.annexUrl">上传附件</view>
				<view v-if="form.annexUrl" @click="upload" class="textName">{{form.fileName}}</view>
			</view>
		</view>
		<view style="background-color: #F6F6F6;height: 10rpx;"></view>
		<!-- <view class="btn" :>提交</view> -->
		<u-button class="btn" @click="comit()" :loading="loading" loadingText="提交中">提交</u-button>
		<!--  操作票类型-->
		<u-picker :show="categoryShow" :columns="options" keyName="dic_key" @cancel="categoryShow =false"
			@confirm="categoryConfirm"></u-picker>
		<tree ref="tree" @comit="treeComit" :treeData="treeData" :type="type"></tree>
		<!-- 设备列表 -->
		<u-popup :show="shebeiShow" mode="bottom" @close="shebeiShow = false">
			<view class="device">
				<view class="devHerders flex  align-items  justify-content-between">
					<view class="devclose" @click="shebeiShow =  false">取消</view>
					<view class="comit" @click="deviceComit">确认</view>
				</view>
				<view class="device_serch">
					<u-search placeholder="设备名称" v-model="names" @custom="getdeviceInfoList" @search="getdeviceInfoList"
						@clear='getdeviceInfoList'></u-search>
				</view>
				<view class="device_list">

					<view class="device_herder flex justify-content-between">
						<view class="device_herder_name">设备位号</view>
						<view class="device_herder_name">设备名称</view>
						<view class="device_herder_name">选中状态</view>
					</view>
					<view class="sordec">
						<view class="device_item flex" v-for="(v,i) in deviceList" :key="i" @click="deviceCak(v)">

							<view class="itemss">{{v.deviceCode}}</view>
							<view class="itemss">{{v.deviceName}}</view>
							<view class="itemss">
								<view class="yuans" v-if="v.deviceId  != device">
								</view>
								<u-icon v-else name="checkmark-circle-fill" color="#267DFF" size="20"></u-icon>
							</view>
						</view>
						<view class=" base" v-if="deviceList.length <=0">
							暂无数据
						</view>
					</view>
				</view>
			</view>
		</u-popup>

		<!--  获取工作票 -->
		<u-popup :show='workShow' mode="bottom" @close="workShow = false">
			<div class="workShow">
				<div class="workShow_herder">
					<div class="workShow_herder_left" @click="workShow =false">取消</div>
					<div class="workShow_herder_right" @click="shebeiShowSubmit">确定</div>
				</div>
				<div class="workShow_title">工作票</div>
				<div  style="height: 800rpx ; overflow-y: scroll;">
					<div class="workShow_item" v-for="(v,i) in faultInfoList" :key="i" @click="faultInfoId = v.fault_id">
						<div class="workShow_left">
							<div class="flex align-items items">
								<div class="workShow_label">
									缺陷编号:
								</div>
								<div class="workShow_val">{{v.fault_no}}</div>
							</div>
							<div class="flex align-items items">
								<div class="workShow_label">
									缺陷类型:
								</div>
								<div class="workShow_val">{{v.fault_class_str}}</div>
							</div>
					
							<div class="flex align-items items">
								<div class="workShow_label">
									申报部门:
								</div>
								<div class="workShow_val">{{v.dept_name}}</div>
							</div>
					
							<div class="flex align-items items">
								<div class="workShow_label">
									申报人员:
								</div>
								<div class="workShow_val">{{v.user_name}}</div>
							</div>
							<div class="flex align-items items">
								<div class="workShow_label">
									申报时间:
								</div>
								<div class="workShow_val">{{v.create_date}}</div>
							</div>
						</div>
					
						<image v-if="v.fault_id == faultInfoId" class="workShow_right" src="/static/img/icon_checked.png">
						</image>
					</div>
				</div>
			
			</div>

		</u-popup>
		<!-- 操作票 -->
		<u-picker :show="pickerShow" :columns="columns" keyName="taskName" @close="pickerShow=false"
			@cancel="pickerShow=false" @confirm="confirm"></u-picker>
		<!-- 操作票模板 -->
		<u-picker :show="templateShow" :columns="templateLists" keyName="taskName" @close="templateShow=false"
			@cancel="templateShow=false" @confirm="templateConfirm"></u-picker>
		<helangcompress ref="helangCompress"></helangcompress>
		<lussTmepleVue ref="lussTmepleVue" @tmpletSubmit="tmpletSubmit"></lussTmepleVue>
		<relation ref="relation" @tmpletSubmit="relationSubmit"></relation>
	</view>
</template>

<script>
	import {
		getDicListByCode,
		lssueAdd,
		getListDeptForZTree,
		sysUserList,
		deviceInfoList,
		getOperateUser,
		getAssociationOrderList,
		templateList,
		getDeptTree,
		getPositionList,
		getUserByPositionId,
		getFaultInfoList
	} from '@/api/lssue.js'
	import urlConfig from "@/request/urlConfig.js";
	import helangcompress from '@/components/helang-compress/helang-compress.vue'
	import lussTmepleVue from '@/components/lussTmeple/lussTmeple.vue';
	import relation from '@/components/relation.vue'
	export default {
		components: {
			helangcompress,
			lussTmepleVue,
			relation
		},
		data() {
			return {
				baseUrl: urlConfig.baseURL,
				templateShow: false,
				templateLists: [],
				keyword: '',
				form: {
					name: '',
					fileName: '',
					taskName: '', //操作票名称
					device: '', //操作设备
					deviceName: '',
					deptId: '', //部门ID
					depatName: '', //	部门名称
					edition: '', //	期
					numberPages: '', //	页数
					category: '', //	操作票类型
					operateUserId: '', //	操作人id
					operateUserName: '',
					guardianUserId: '', //	监护人id
					guardianUserName: '',
					shiftSupervisorId: '', //	值长id
					shiftSupervisorName: "", //名称
					monitorUserId: '', //	 值班长
					monitorUserName: '', //
					annexUrl: '', //附件url
					listRisk: [], //操作票-风险措施表
					listProcess: [], //操作票-流程模板表
					parentId: '',
					parentName: '',
					operateType: '1',
					preparationContent: `1、获取作业许可2、填写操作安全分析`,
					shutdownContent: '在此本人已经授权，不惧怕任何谴责或报复，立即停止所有危害到公众、工友和本人的工作活动；对该情况的质疑、校正行为都不能认为是不遵守我们的安全和健康准则；将所有不安全情况和行为上报给监管部门，对任何涉及违反已建立的安全、健康守则的活动提出质疑。'
				},
				value3: 10,
				options: [],
				cancelOption: [],
				categoryShow: false,
				treeData: [],
				treeDataTwo: [],
				keyName: '', //定义一个字段名称
				keyId: '', //定一个字段id
				DEPT_ID: '',
				type: '0', //0部门单选 1用户单选 2用户多选
				state: 0,
				deviceList: [],
				loading: false,
				shebeiShow: false,
				names: "",
				device: '',
				deviceName: '',
				pickerShow: false,
				columns: [],
				treeDataTher: [],
				faultInfoList: [],
				workShow: false,
				faultInfoId:'',
				fault_class_str:'',
			};
		},
		onLoad(option) {
			const currentUrl = window.location.href;
			console.log(currentUrl, "currentUrl");
			const token = this.getUrlParams("token");
			if (token) {
				uni.setStorageSync('token', token)
			}
			this.getDicList()
			this.onSubmitList()
			this.getdeviceInfoList()
			this.getuser()
			this.getGetAssociationOrderList()
			this.gettemplateList()
			this.getDeptTrees()
			this._getFaultInfoList()
			getApp().globalData.listRisk = []
			getApp().globalData.listProcess = []
		},
		onShow() {
			uni.$once('risk', e => {
				console.log('risk返回值', e);
				this.form.listRisk = [...e]
				getApp().globalData.listRisk = [...e]
			})
			uni.$once("process", e => {
				console.log('process返回值', e);
				this.form.listProcess = [...e]
				getApp().globalData.listProcess = [...e]
			})
		},

		methods: {
			clsoeWork(){
				this.fault_class_str =  ''
				this.faultInfoId = ''
			},
			shebeiShowSubmit(){
				if(!this.faultInfoId) return uni.$u.toast('请选择工单')
				const info = this.faultInfoList.find(v=>v.fault_id == this.faultInfoId)
				 this.fault_class_str =  info.fault_class_str
				 this.faultInfoId = info.fault_id
				 this.workShow =false
				console.log(info,"info_____________-")
				
			},
			_getFaultInfoList() {
				getFaultInfoList().then(res => {
					console.log(res);
					this.faultInfoList = [...res.datas]
				})
			},
			pickerAdd() {
				this.$refs.relation.shebeiShow = true
			},
			// 获取关联票
			relationSubmit(val) {
				console.log(val);
				this.form.parentName = val.taskName
				this.form.parentId = val.id

			},
			clarParen() {
				this.form.parentId = ''
				this.form.parentName = ''
			},
			templateBtn() {
				this.$refs.lussTmepleVue.shebeiShow = true

			},
			templateConfirm({
				value
			}) {
				this.formFun(value[0])
				this.form.name = value[0].taskName
				console.log(this.form, "e");
				this.templateShow = false
			},
			tmpletSubmit(e) {
				this.formFun(e)
				this.form.name = e.taskName
				console.log(this.form, "e");
			},
			async gettemplateList() {
				this.device = ''
				const res = await templateList()
				console.log(res, "gettemplateList");
				this.templateLists = [res.rows]
				console.log(this.templateLists, "templateLists");

			},
			async getGetAssociationOrderList() {
				const res = await getAssociationOrderList({
					id: ''
				})
				console.log(res, "getGetAssociationOrderList");
				this.columns.push(res.datas)
			},
			confirm({
				value
			}) {
				console.log(value, "e");
				this.form.parentName = value[0].taskName
				this.form.parentId = value[0].id
				this.pickerShow = false
			},
			jumpTos(url, type) {
				if (type == 1) {
					getApp().globalData.listRisk = [...this.form.listRisk]
					// })
					// uni.$once("process", e => {
					// 	console.log('process返回值', e);
					// 	this.form.listProcess = [...e]
					// 	getApp().globalData.listProcess = [...e]
				} else {
					getApp().globalData.listProcess = [...this.form.listProcess]
				}
				this.jumpTo(url)
			},
			async getuser() {
				const res = await getOperateUser()
				console.log(res, "getuser");
				this.form.operateUserId = res.datas.login_user_id
				this.form.operateUserName = res.datas.login_user_name
				this.form.deptId = res.datas.login_dept_id
				this.form.depatName = res.datas.login_dept_name
			},
			getUrlParams(name, url) {
				if (!url) url = window.location.href;
				name = name.replace(/[\[\]]/g, '\\$&');
				var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
					results = regex.exec(url);
				if (!results) return null;
				if (!results[2]) return '';
				return decodeURIComponent(results[2].replace(/\+/g, ' '));
			},
			getSysUserList(DEPT_ID) {
				sysUserList({
					PAGE_NO: 1,
					PAGE_SIZE: 10000,
					DEPT_ID: DEPT_ID,
					DEPT: DEPT_ID,
				}).then(res => {
					this.treeData = JSON.parse(res.datas).rows.map(v => {
						return {
							label: v.user_name,
							id: v.user_id,
							checked: false,
						}
					})
					if (this.type == 1) {
						this.$refs.tree.itemclick(false, false)
						this.type = 4
					}
					if (this.type == 2) {
						this.$refs.tree.itemclick(true, false)
					}
					this.state = 1
				})
			},
			getSysUserListTwo(DEPT_ID) {
				getUserByPositionId({
					PAGE_NO: 1,
					PAGE_SIZE: 10000,
					posId: DEPT_ID,
				}).then(res => {
					this.treeData = res.rows.map(v => {
						return {
							label: v.user_name,
							id: v.user_id,
							checked: false,
						}
					})
					if (this.type == 1) {
						this.$refs.tree.itemclick(false, false)
					}
					if (this.type == 2) {
						this.$refs.tree.itemclick(true, false)
					}
					this.state = 1
				})
			},
			// 获取设备
			async getdeviceInfoList() {
				const res = await deviceInfoList({
					PAGE_NO: 1,
					PAGE_SIZE: 100000,
					name: this.names
				})
				console.log(res, "res");
				// this.deviceList = res.rows.map(v => {
				// 	return {
				// 		id: v.deviceId,
				// 		label: v.deviceName,
				// 		checked: false,
				// 	}
				// })
				this.deviceList = res.rows
				console.log(res, "res");
			},
			onSubmitList() {
				getListDeptForZTree().then((res) => {
					console.log(res);
					this.treeData = res.datas.map(ele => this.treeStructure(ele));
					this.treeDataTwo = res.datas.map(ele => this.treeStructure(ele));
					console.log(this.treeData, "treeData");
				});
			},
			treeStructure(ele) {
				const haveChildren = Array.isArray(ele.children) && ele.children.length > 0;
				return {
					id: ele.value,
					label: ele.label,
					checked: false,
					children: haveChildren ? ele.children.map(i => this.treeStructure(i)) : [],
				}
			},

			// 获取所有岗位
			async getDeptTrees(posCode ='') {
				const res = await getPositionList({
					posCode: posCode
				})
				console.log(res, "getPositionList");
				this.treeDataTher = res.datas.map(v => {
					return {
						id: v.posId,
						label: v.posName
					}
				})
			},
			// 提交
			comit() {
				if (this.validateForm()) {
					this.loading = true
					uni.showLoading({
						title: '提交中'
					})

					lssueAdd({
						...this.form,
						faultInfoId:this.faultInfoId || ''
					}).then(res => {
						console.log(res);
						uni.hideLoading()
						uni.$u.toast('新增成功')
						setTimeout(() => {
							uni.navigateBack()
							this.loading = false
							window.android.backWeb()
						}, 300)

					}).catch(error => {
						uni.hideLoading()
						this.loading = false;
					});
				} else {
					// 数据有空项，不执行提交逻辑
					console.log('请填写完整的表单信息');
					uni.$u.toast('请填写完整的表单信息')
				}
			},
			// 验证 form 中的数据是否某一项为空（排除 fileName 和 edition），如果某一项为空则不提交
			validateForm() {
				for (const key in this.form) {
					if (key != 'annexUrl' && key != 'name' && key != 'edition' && key != 'listRisk' && key != 'fileName' && key !=
						'numberPages' && key !=
						'device' && key !=
						'parentId' && key != 'parentName' && this.form[
							key] == '') {
						console.log(`字段 ${key} 为空，请填写完整`);
						return false; // 某一项为空，返回 false
					}
				}
				return true; // 所有项都不为空，返回 true
			},
			categoryConfirm({
				value
			}) {
				this.form.category = value[0].dic_key
				this.categoryShow = false
			},
			async claick(id, name, type) {
				if(id == 'monitorUserId'){
					await this.getDeptTrees('CZP001')
				}else if( id == 'shiftSupervisorId'){
					await this.getDeptTrees('CZP002')
				}else{
					await this.getDeptTrees()
				}
				console.log(211111111);
				this.state = 0
				this.keyId = id
				this.keyName = name
				if (id == 'monitorUserId' || id == 'shiftSupervisorId' || id == "guardianUserId") {
					this.treeData = this.treeDataTher
				} else {
					this.treeData = this.treeDataTwo
				}
				this.type = type
				if (type == 3) {
					// this.treeData = this.deviceList
					// this.$refs.tree.itemclick(false, true)
					this.shebeiShow = true
					this.names = ''
					this.getdeviceInfoList()
				} else {
					this.$refs.tree.itemclick(false, true)
				}
			},
			treeComit(e) {
				console.log(e, this.state, "String");
				if (this.state == 0) {
					console.log(e, "e");
					if (this.type == 0 || this.type == 3) {
						this.form[this.keyId] = e[0].id
						this.form[this.keyName] = e[0].label
					} else {
						console.log('获取值')
						if (this.keyId == 'operateUserId') {
							this.getSysUserList(e[0].id)

						} else {
							this.getSysUserListTwo(e[0].id)
						}
					}
				}
				if (this.state == 1) {
					if (this.type == 1 || this.type == 4) {
						this.form[this.keyId] = e[0].id
						this.form[this.keyName] = e[0].label
					}
					if (this.type == 2) {
						this.form[this.keyId] = e.map(v => v.id).join(',')
						this.form[this.keyName] = e.map(v => v.label).join(',')
					}
					this.state = 0
				}
			},
			deviceCak(v) {
				this.device = v.deviceId
				this.deviceName = v.deviceName

			},
			deviceComit() {
				this.form.device = this.device
				this.form.deviceName = this.deviceName
				this.shebeiShow = false
			},
			getDicList() {
				getDicListByCode({
					DIC_CODE: "OPERATION_TICKET"
				}).then((res) => {
					console.log(JSON.parse(res.datas));
					this.options = [JSON.parse(res.datas).datas]
				})
				getDicListByCode({
					DIC_CODE: "REASON_INVALIDATION"
				}).then((res) => {
					let arrObj =
						this.cancelOption = JSON.parse(res.datas).datas
				})
			},
			upload() {
				uni.chooseFile({
					count: 1,
					type: 'all',
					success: (res) => {
						console.log(res, "res");
						// 选择成功，获取文件路径
						const filePath = res.tempFilePaths[0];
						const fileName = res.tempFiles[0].name;
						uni.showLoading({
							title: '上传中'
						})
						const fileType = res.tempFiles[0].type;
						if (fileType.startsWith('image/')) {
							// return 'image'; // 图片类型
							let that = this;
							this.$refs.helangCompress
								.compress(res.tempFiles[0], that, 1)
								.then((uploadRes) => {
									console.log(uploadRes, "res");
									// this.list[idx].file.push({
									// 	url: urlConfig.nearbyUrl + uploadRes.datas.file_path,
									// 	urlTwo: uploadRes.datas.file_url,
									// })
									// console.log(this.list[idx]);
									this.form.annexUrl = uploadRes.datas.file_url
									this.form.annexUrl1 = uploadRes.datas.file_path
									this.form.fileName = uploadRes.datas.name
									this.$forceUpdate()
								});
						} else {
							uni.uploadFile({
								url: this.baseUrl + '/sys/file/uploadFile', // 替换为实际的上传接口地址
								filePath: filePath,
								name: 'file',
								formData: {
									fileName: fileName // 将文件名作为参数传递给接口
								},
								header: {
									'User-Token': uni.getStorageSync('token') || "",
								},
								success: (uploadRes) => {
									console.log('上传成功', JSON.parse(uploadRes.data));
									this.form.annexUrl1 = JSON.parse(uploadRes.data).datas
										.file_path
									this.form.annexUrl = JSON.parse(uploadRes.data).datas.file_url
									this.form.fileName = JSON.parse(uploadRes.data).datas.file_url
									uni.hideLoading()
								},
								fail: (err) => {
									// 上传失败，处理错误信息
									console.log('上传失败', err);
									uni.hideLoading()
								}
							});
						}
						// 调用上传文件接口

					},
					fail: (err) => {
						// 选择失败，处理错误信息
						console.log('选择文件失败', err);
						uni.$u.toast(err)
					}
				});
			},
			formFun(e) {
				this.form.taskName = e.taskName
				this.form.category = e.category
				this.form.device = e.deviceId
				this.form.deviceName = e.deviceName
				this.form.deptId = e.deptId
				this.form.edition = e.edition
				this.form.preparationContent = e.preparationContent
				this.form.shutdownContent = e.shutdownContent
				this.form.listRisk = e.listRisk
				this.form.listProcess = e.listProcess
				this.form.listProcess.forEach((v) => {
					v.shopList = v.content.split(',').map((v) => {
						return {
							value: v,
						}
					})
				})

				console.log(this.form, "   this.form")
			},
		}
	}
</script>

<style lang="scss" scoped>
	.pages {
		padding: 0 31rpx;
	}

	.herder {
		height: 90rpx;
		background: #FFFFFF;
		padding: 29rpx 0;
		font-family: PingFangSC, PingFang SC;
		font-weight: 500;
		font-size: 33rpx;
		color: #000000;
		text-align: left;
		font-style: normal;
		border-bottom: 1rpx solid #E6E6E6;
	}

	.item {
		min-height: 80rpx;
		border-bottom: 1rpx solid #E6E6E6;

		&_left {
			width: 196rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 33rpx;
			line-height: 47rpx;
			text-align: left;
			font-style: normal;
			color: #666666;
		}

		&_left::before {
			content: '*';
			color: #FF0000;
		}

		&_right {
			flex: 1;

			/deep/.u-input {
				height: 65rpx;
				margin: 0 auto;
				font-size: 16rpx;
			}
		}

		&_fu {
			width: 196rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 33rpx;
			line-height: 47rpx;
			text-align: left;
			font-style: normal;
			color: #666666;
		}

		&_upload {
			width: 240rpx;
			height: 60rpx;
			background: #267DFF;
			text-align: center;
			line-height: 60rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 29rpx;
			color: #FFFFFF;
		}

	}

	.btn {
		background: #267DFF;
		width: 100%;
		height: 89rpx;
		text-align: center;
		line-height: 89rpx;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 29rpx;
		color: #FFFFFF;
	}

	/deep/.placeholderClass {
		font-weight: 400;
		font-size: 24rpx;
		color: #CCCCCC;
	}

	/deep/.uni-textarea-textarea {
		font-size: 32rpx;
	}

	.textName {
		width: 560rpx;
		word-wrap: break-word;
		white-space: pre-line;
		text-align: right;
	}

	.device {
		height: 1000rpx;
		padding: 0 30rpx;
		padding-top: 30rpx;

		&_serch {
			margin-top: 20rpx;
		}

		.devHerders {
			.devclose {
				font-size: 30rpx;
				color: rgb(144, 145, 147);
			}

			.comit {
				font-size: 30rpx;
				color: rgb(60, 156, 255);
			}

		}

		&_herder {
			margin-top: 20rpx;
			border: 1rpx solid #E6E6E6;
			border-right: none;
			height: 70rpx;

			view {
				text-align: center;
				border-right: 1rpx solid #E6E6E6;
				font-size: 28rpx;
				flex: 1;
				line-height: 70rpx;
			}

		}

		&_item {
			min-height: 80rpx;
			border-bottom: 1rpx solid #e6e6e6;
			border-left: 1rpx solid #E6E6E6;

			.itemss {
				text-align: center;
				border-right: 1rpx solid #E6E6E6;
				font-size: 28rpx;
				flex: 1;
				display: flex;
				justify-content: center;
				align-items: center;
				word-wrap: break-word;
				word-break: break-all;
			}
		}
	}

	.sordec {
		height: 790rpx;
		overflow-y: scroll;
	}

	.base {
		text-align: center;
		margin-top: 80rpx;
		font-size: 30rpx;
	}

	.yuans {
		display: flex;
		width: 40rpx;
		height: 40rpx;
		border: 1rpx solid #E6E6E6;
		border-radius: 50%;
	}

	.mshh {
		display: flex;
		align-items: center;
		margin-right: 20rpx;
		font-size: 33rpx;

		image {
			width: 40rpx;
			height: 40rpx;
			margin-right: 10rpx;
		}
	}

	/deep/.uni-input-input {
		font-size: 24rpx;
	}

	// /deep/.u-textarea{
	// 	flex-direction:  !important;
	// }
	.workShow {
		padding: 30rpx;
		&_title{
			font-size: 32rpx;
			text-align: center;
			font-weight: 600;
			padding-bottom: 10rpx;
		}
		&_item{
			margin-top: 20rpx;
			position: relative;
			border: 1rpx solid #E6E6E6;
			border-radius: 8rpx;
			padding: 10rpx;
		}
		.items{
			margin-top: 6rpx;
		}
		&_herder{
			display: flex;
			align-items: center;
			justify-content: space-between;
		}
		&_right{
			font-size: 28rpx;
			width: 40rpx;
			height: 40rpx;
			position: absolute;
			right: 20rpx;
			top: 25rpx;
		}
	}
</style>